package com.hkzhao.reportingsystem.component;

import com.hkzhao.reportingsystem.service.DoctorService;
import com.hkzhao.reportingsystem.service.NormalUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class UpdateTask {
    @Autowired
    private NormalUserService normalUserService;
    @Autowired
    private DoctorService doctorService;
    /**
     * cron表达式：Seconds Minutes Hours DayofMonth Month DayofWeek [Year]
     * <p>
     * 每10分钟扫描一次
     */
    @Scheduled(cron = "0 0/2 * ? * ?")
    private void updateStars()
    {
        normalUserService.updateStarsNumInMysql();
    }

    //每天执行一遍 林晨12点
    @Scheduled(cron = "0 0 0 * * ?")
    private void updateRecord(){
        doctorService.addRecordInMongo();
    }
    //每天执行一遍 林晨12点
    @Scheduled(cron = "0 0 0 * * ?")
    private void updateTotalDate(){doctorService.addDiagnosisInMongo();}
}
